﻿<!doctype html>
<html lang="en">
<head>
    <script type="text/javascript" src="js/jquery-2.1.3.js"></script>
    <script type="text/javascript" src="js/highstock.js"></script>
    <script type="text/javascript" src="js/modules/exporting.js"></script>
    <script type="text/javascript" src="js/chu/chu_common.js"></script>
    <script>
        $(function () {
            var industry1 = "industry1", industry2 = "industry2", location = "location";
            industry1 = chu_common.parsepara(industry1);
            industry2 = chu_common.parsepara(industry2);
            location = chu_common.parsepara(location);
            //alert(industry1);
            //for (var i = 0; i < d.length; i++) {
            //    var keyValue = d[i].split('=');
            //    var key = keyValue[0];
            //    var value = keyValue[1];
            //    if (key == "industry1") industry1 = value;
            //    if (key == "industry2") industry2 = value;
            //    if (key == "location") location = value;
            //    //alert('the key is:' + key);
            //    //alert('the value is:' + value);
            //}
            //<tr><th>id</th><th>name</th><th>total</th><th>float</th><th>first</th><th>second</th><th>weight</th></tr>

            var stock = $("#stock").val();
            var url;
            if(industry1!="" || industry2!="") {
                if (industry2=="")
                    url = "/rest/rest/info/industry1/" + industry1;
                else
                    url = "/rest/rest/info/industry1/" + industry1 + "/industry2/" + industry2;
            }
            if (location != "") {
                url = "/rest/rest/info/location/" + location;
            }
                $.ajaxSetup({ async: false });
                var t = $.getJSON(url);
                for (var i in t.responseJSON) {
                    var newRow = "<tr>";
                    var weight = t.responseJSON[i]["weight"];
                    var sid = t.responseJSON[i]["sid"];
                    var link = "<a target='_parent' href='/web/single_dynamic.html?sid=" + sid + "&big=" + 500*weight + "'>" + sid + "</a>";
                    newRow += "<td>" + link + "</td>";
                    newRow+="<td>"+t.responseJSON[i]["name"]+"</td>";
					
                    newRow+="<td>"+t.responseJSON[i]["totalshare"]+"</td>";
                    newRow+="<td>"+t.responseJSON[i]["floatshare"]+"</td>";
					var ind1=t.responseJSON[i]["firstlevel"];
					var ind2=t.responseJSON[i]["secondlevel"];
					var loc=t.responseJSON[i]["location"];
					var ind_link1="<a target='_parent' href='/web/company.html?industry1=" + ind1+"'>"+ind1+"</a>";
                    newRow+="<td>"+ind_link1+"</td>";
					var ind_link2="<a target='_parent' href='/web/company.html?industry1=" + ind1+"&industry2="+ind2+"'>"+ind2+"</a>";
                    newRow+="<td>"+ind_link2+"</td>";
					var loc_link="<a target='_parent' href='/web/company.html?location=" + loc+"'>"+loc+"</a>";
					newRow += "<td>" + loc_link + "</td>";
                    newRow += "<td>" + weight + "</td>";
                    $("#table1 tr:last").after(newRow);
                }
            });
            ;

    </script>
</head>
<body>
    <div id="input">
        <table id="table1" border="1"><tr><th>id</th><th>name</th><th>total</th><th>float</th><th>first</th><th>second</th><th>location</th><th>weight</th></tr></table>
    </div>

    <a id="industry1" href=""></a>
    
</body>
</html>